<%--
  Created by IntelliJ IDEA.
  User: 31324
  Date: 2025/6/14
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
  <link rel="stylesheet" href="/layui/css/layui.css">
  <script src="/layui/layui.js"></script>
  <script src="/layui/jquery-3.6.0.min.js"></script>
  <script>
    $(function () {
      layui.use(['laypage', 'layer', 'form'], function () {
        var laypage = layui.laypage
                , layer = layui.layer
                , form = layui.form;
        //分组件
        laypage.render({
          elem: 'pagesData'
          , count: ${pageInfo.total}
          , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
          , limit: ${pageInfo.pageSize}
          , limits: [5, 10, 15]
          , curr:${pageInfo.pageNum}
          , jump: function (obj, first) {
            //首次不执行
            if (!first) {
              if (obj.curr !=${pageInfo.pageNum}) {
                location.href = "/permission/findAll?page=" + obj.curr + "&limit=" + obj.limit;
              } else if (obj.limit !=${pageInfo.pageSize}) {
                location.href = "/permission/findAll?page=1&limit=" + obj.limit;
              }
            }
          }


        });

      });


    })

    function delids(id, name) {
      //询问框
      layer.confirm('确定删除权限[' + name + ']？', {
        btn: ['确定', '取消'] //按钮
      }, function () {
        location.href = "/permission/deleteById?id=" + id;
        // return true;
        //layer.msg('的确很重要', {icon: 1});
      }, function () {
        //  return false;
      });
    }
  </script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>权限列表</legend>
</fieldset>
<div class="layui-bg-gray" style="padding: 0px;">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body">
          <form class="layui-form" action="">
            <div class="layui-form-item">

              <div class="layui-input-inline">
                <a href="/page/permission/permission-add.jsp" class="layui-btn layui-btn-sm">
                  <i class="layui-icon layui-icon-search"></i>权限添加
                </a>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>


    <!--数据列表-->
    <table id="dataList" class="layui-table">
      <thead>
      <tr>

        <th>ID</th>
        <th>权限名称</th>
        <th>权限URL</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <c:forEach items="${pageInfo.list}" var="permission">
        <tr>
          <td>${permission.id }</td>
          <td>${permission.permissionName }</td>
          <td>${permission.url }</td>

          <td>
              <%--修改--%>
            <a title="修改" class="layui-btn layui-btn-warm layui-btn-xs"
               href="${pageContext.request.contextPath}/permission/findById?id=${permission.id}"> 修改</a>
              <%--删除--%>
            <button class="layui-btn layui-btn-danger layui-btn-xs" title="删除"

                    onclick="delids(${permission.id},'${permission.permissionName}')"><i
                    class="layui-icon layui-icon-delete"></i> <span
                    class="glyphicon glyphicon-trash"></span>
            </button>

          </td>
        </tr>
      </c:forEach>
      </tbody>
    </table>
    <!--分页-->
    <div id="pagesData"></div>

  </div>
</div>
</body>
</html>
